package com.t216.dm216.controller;

import com.t216.dm216.common.Result;
import com.t216.dm216.pojo.dto.DmItemParamDTO;
import com.t216.dm216.pojo.dto.DmItemTypeDTO;
import com.t216.dm216.service.DmItemService;
import com.t216.dm216.service.DmItemTypeService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/item/api/p/index")
public class DmItemIndexApiController {
    @Resource
    private DmItemTypeService dmItemTypeService;

    @Resource
    private DmItemService dmItemService;
    @PostMapping("/queryAllType")
    public Result<List<DmItemTypeDTO>> queryAllType(){
        //ctrl + alt + 左键
        return Result.success(dmItemTypeService.queryAllType());
    }

    @PostMapping("/queryTransverse")
    public Result queryTransverse(){
        return Result.success(dmItemTypeService.queryLevel1Type());
    }

    @PostMapping("/queryTodayRecommend")
    public Result queryTodayRecommend(){
        return Result.success(dmItemService.getRecommendItem());
    }

    @PostMapping("/queryFloorItems")
    public Result queryFloorItems(){
        return Result.success(dmItemTypeService.queryFloorItems());
    }

    /**
     * entity domain pojo
     * @param itemParamDTO
     * @return
     */
    @PostMapping("/queryHotItems")
    public Result queryHotItems(@RequestBody DmItemParamDTO itemParamDTO){
        return Result.success(dmItemService.getHotItems(itemParamDTO.getItemTypeId()));
    }
}
